﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OOAD_Project_Editor.Foundation;
using OOAD_Project_Engine.Domain.Factories;

namespace OOAD_Project_Editor.Domain
{
    class ActionFactory
    {
        public static IManageSceneAction CreateAction(EActionType _type, params object[] param)
        {
            IManageSceneAction action = null;
            Type actionType = null;
            foreach (Type t in typeof(ManageSceneAction).Assembly.GetTypes())
            {
                object[] attributes = t.GetCustomAttributes(typeof(ActionAttribute), true);
                foreach (Object attribute in attributes)
                {
                    ActionAttribute a = attribute as ActionAttribute;
                    if (a.ActionType == _type)
                        actionType = t;
                }
            }
            if (actionType == null)
                throw new Exception();

            action = Factory.Create(actionType, param) as IManageSceneAction;

            return action;
        }
    }
}
